#!/bin/bash

source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/alias.sh"
source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/conda_and_pip_settings.sh"

APP_INSTALL_NAME="thinksound"
APP_TARGET_DIR_NAME="thinksound"
CONDA_ENV_NAME=$APP_INSTALL_NAME
CONDA_PREFIX="./venv"

export CURRENT_APP_PATH="${LMD_APPS_DIR}/${APP_TARGET_DIR_NAME}"
echo 'App Dir: '${CURRENT_APP_PATH}

cd "$CURRENT_APP_PATH"
python --version
pip --version

if [ -z "$HF_ENDPOINT" ] && [ -n "$HF_MIRROR" ]; then
    export HF_ENDPOINT="$HF_MIRROR"
fi


export GRADIO_TEMP_DIR="$CURRENT_APP_PATH/gradio_temp"

export HF_HOME="./tmp_hf_home"
export U2NET_HOME="./unet_home"
export TORCH_HOME="./tmp_torch_home"


echo "use ./venv to start app. "$CONDA_PREFIX

export PYTHONIOENCODING="utf-8"

conda run -p $CONDA_PREFIX --no-capture-output python app.py

